import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(home: DefaultTextStyleExample()));
  // runApp(MaterialApp(home: zujian2()));
}

class zujian2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      //1.设置文本默认样式
      style: TextStyle(
        color: Colors.red,
        fontSize: 20.0,
      ),
      textAlign: TextAlign.start,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text("hello world"),
          Text("I am Jack"),
          Text(
            "I am Jack",
            style: TextStyle(
                inherit: false, //2.不继承默认样式
                color: Colors.grey),
          ),
        ],
      ),
    );
  }
}
class DefaultTextStyleExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: TextStyle(
        fontSize: 18.0, // 设置字体大小
        color: Colors.white, // 设置字体颜色
        fontWeight: FontWeight.bold, // 设置字体粗细
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text('这是一个示例文本'),
          Text('这是另一个示例文本'),
        ],
      ),
    );
  }
}
class zujian1 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text.rich(TextSpan(children: [
      TextSpan(text: "Home: "),
      TextSpan(
        text: "https://flutterchina.club",
        style: TextStyle(color: Colors.blue),
      ),
    ]));
  }
}

class zujian extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
        children: [
          Text(
            '123' * 3,
          ),
          Text(
            '123' * 3,
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
          ),
          Text(
            '123' * 3,
            maxLines: 1,
            textScaler: TextScaler.linear(1.5),
            overflow: TextOverflow.ellipsis,
          ),
          Text(
            '123sssssssssss' * 3,
            maxLines: 1,
            style: TextStyle(
                color: Colors.red, fontSize: 18, backgroundColor: Colors.green),
            textScaler: TextScaler.linear(1.5),
            overflow: TextOverflow.ellipsis,
          ),
        ],
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center);
  }
}
